import { dicCreateSchema } from "~/validators/dic";
export default defineEventHandler(async (event) => {
  const result = await runValidate(dicCreateSchema, event);
  const { code } = result.data;
  const dic = await DicSchema.findOne({ code: code }).lean();
  if (dic) {
    throw createError({
      statusCode: 409,
      statusMessage: "该字典已存在，请修改后重试",
    });
  }
  const newDic = await DicSchema.create(result.data);
  return newDic;
});
